function buildHeaderTree(columns: ColumnConfig[]): ColumnConfig[] {
    const rootColumns: ColumnConfig[] = [];
    const assignLevelAndParent = (column: ColumnConfig, level: number, parent?: ColumnConfig) => {
        column.level = level;
        column.parent = parent;
        if (column.children && column.children.length > 0) {
            column.children.forEach(child => assignLevelAndParent(child, level + 1, column));
        }
        if (!parent) {
            rootColumns.push(column);
        }
        return column;
    };
    columns.forEach(column => assignLevelAndParent(column, 0));
    return rootColumns;
}